<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>登录</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/signin.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
</head>
<body class="text-center">
    <form class="form-signin">
        <img class="mb-4" alt="" src="${pageContext.request.contextPath}/static/img/employ.svg" width="72" height="72">
        <input type="text" name="eid" id="eid" class="form-control" placeholder="工号" required="" autofocus="">
        <input type="password" name="password" id="password" class="form-control" placeholder="密码" required="">
        <button class="btn btn-lg btn-primary btn-block" type="button" id="submitLogin">登录</button>
        <a class="btn btn-lg btn-info btn-block" href="${pageContext.request.contextPath}/toRegister" >注册</a>
        <p class="mt-5 mb-3 text-muted">2022.12.18</p>
    </form>
</body>
<script type="module">
    $('#submitLogin').on('click',function (){
        let eid = $('#eid').val();
        let password = $('#password').val();
        $.ajax({
            url:'http://localhost:8080/login/',
            type:'post',
            data:{
                eid:eid,
                password:password
            },
            success(resp){
                if(resp === 'false'){
                    alert("账号和密码不匹配");
                }else{
                    location.href="/myInfo/"+eid
                }
            }
        })
    })
</script>
</html>